package com.htc.adapter;

import java.util.ArrayList;

import com.htc.dlc.R;
import com.htc.model.dto.SpaParentDTO;
import com.htc.utils.CommonActions;
import com.htc.utils.CommonObjects;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SpinnerAdapter extends ArrayAdapter<SpaParentDTO> {
	CommonActions ca;
	Context mContext;
	private LayoutInflater mInflater;
	ArrayList<SpaParentDTO> mList;
	public String selectedString;

	public SpinnerAdapter(Context paramContext, int paramInt,
			ArrayList<SpaParentDTO> paramArrayList) {
		super(paramContext, paramInt, paramArrayList);
		this.mList = paramArrayList;
		this.mContext = paramContext;
		this.mInflater = LayoutInflater.from(paramContext);
		this.ca = new CommonActions(paramContext);
	}

	public int getCount() {
		if (this.mList != null)
			return this.mList.size();
		return 0;
	}

	public View getDropDownView(int paramInt, View paramView,
			ViewGroup paramViewGroup) {
		return getView(paramInt, paramView, paramViewGroup);
	}

	public long getItemId(int paramInt) {
		return paramInt;
	}

	public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
		ViewHolder localViewHolder = null;
		if (paramView == null) {
			paramView = this.mInflater.inflate(R.layout.spa_spinner_row, null);

		}
		localViewHolder = new ViewHolder();
		localViewHolder.txt_spinner = ((TextView) paramView
				.findViewById(R.id.txt_spinner));
		localViewHolder.txt_spinner.setText(((SpaParentDTO) this.mList
				.get(paramInt)).getSpaTitle());
		if (getItem(paramInt) != null) {
			if (!CommonObjects.testEmpty(this.selectedString)) {
				if (!localViewHolder.txt_spinner.getText().toString()
						.equalsIgnoreCase(this.selectedString))
					localViewHolder.txt_spinner.setTextColor(this.mContext
							.getResources().getColor(R.color.skyblue));
				localViewHolder.txt_spinner.setTextColor(this.mContext
						.getResources().getColor(R.color.black));
			}

		}

		return paramView;
	}

	private class ViewHolder {
		public TextView txt_spinner;

	}
}